/*
 * @Author: Lzx
 * @Date: 2022-04-16 11:37:51
 * @LastEditors: Lzx
 * @LastEditTime: 2022-04-16 11:43:44
 * @FilePath: /web-vue/src/utils/datePicker.js
 * @Description: 日期选择组件，快捷选项
 */
// 日期选择器：快捷方式
export const Date_Picker_Option = {
  shortcuts: [
    {
      text: "今天",
      onClick(picker) {
        picker.$emit("pick", new Date());
      },
    },
    {
      text: "昨天",
      onClick(picker) {
        const date = new Date();
        date.setTime(date.getTime() - 3600 * 1000 * 24);
        picker.$emit("pick", date);
      },
    },
    {
      text: "一周前",
      onClick(picker) {
        const date = new Date();
        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
        picker.$emit("pick", date);
      },
    },
  ],
};

// 日期范围选择器：快捷方式
export const DateRange_Picker_Option = {
  shortcuts: [
    {
      text: "最近一周",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近一个月",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近三个月",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
        picker.$emit("pick", [start, end]);
      },
    },
  ],
};

// 日期时间范围选择器：快捷方式
export const DateTimeRange_Picker_Option = {
  shortcuts: [
    {
      text: "今天",
      onClick(picker) {
        const start = new Date();
        const end = new Date();
        end.setTime(start.getTime() + 3600 * 1000 * 24);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "未来两天",
      onClick(picker) {
        const start = new Date();
        const end = new Date();
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 2);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "未来一周",
      onClick(picker) {
        const start = new Date();
        const end = new Date();
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 7);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "未来一个月",
      onClick(picker) {
        const start = new Date();
        const end = new Date();
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 30);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近一周",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近一个月",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近三个月",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
        picker.$emit("pick", [start, end]);
      },
    },
  ],
};
